import axios from "axios";

const instance = axios.create({
  baseURL: "http://kumanxuan1.f3322.net:8001",
  timeout: 5000,
});
instance.interceptors.request.use((config) => {
  // console.log(11111);
  // console.log("执行了请球拦截代码");
  let token = localStorage.getItem("token");
  if (token) {
    config.headers["X-Nideshop-Token"] = token;
  }
  return config;
}),
  (err) => {
    return Promise.reject(err);
  };

instance.interceptors.response.use((res) => {
  // console.log(222222)
  let data = res.data;
  if (data.errno !== 0) {
    console.log(data.errmsg);
  }
  return data;
}),
  (err) => {
    return Promise.reject(err);
  };
export default instance;
